package com.kly.user.db.dao.impl;
import com.alibaba.excel.util.StringUtils;
import com.fqgj.common.base.AbstractBaseMapper;
import com.google.common.collect.Maps;
import com.kly.user.db.dao.UserPpvUnlockRecordDao;
import com.kly.user.db.entity.UserPpvUnlockRecordEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;

/**
* User: linqu
* Date: 2024-04-23
* Time: 13:45:27.559
*/

@Repository
public class UserPpvUnlockRecordDaoImpl extends AbstractBaseMapper<UserPpvUnlockRecordEntity> implements UserPpvUnlockRecordDao {

    @Override
    public UserPpvUnlockRecordEntity addPPVLog(String requestId, String userCode, String modelUserCode, String chatterUserCode,
                                               Integer benefitCode, String msgId, String imageCode, String imageUrl) {

        if (StringUtils.isBlank(requestId)) {
            return null;
        }
        UserPpvUnlockRecordEntity entity = new UserPpvUnlockRecordEntity();
        entity.setRequestId(requestId);
        entity.setUserCode(userCode);
        entity.setModelUserCode(modelUserCode);
        entity.setChatterUserCode(chatterUserCode);
        entity.setBenefitCode(String.valueOf(benefitCode));
        entity.setMsgId(msgId);
        entity.setImageCode(imageCode);
        entity.setImageUrl(imageUrl);
        return this.insert(entity);
    }

    @Override
    public Integer updateResult(String requestId, Integer status, String result, String imageCode, String imageUrl, String chatterUserCode) {
        final HashMap<Object, Object> params = Maps.newHashMap();
        params.put("requestId", requestId);
        params.put("status", status);
        params.put("result", result);
        params.put("imageCode", imageCode);
        params.put("imageUrl", imageUrl);
        params.put("chatterUserCode", chatterUserCode);
        return this.getSqlSession().update(this.getStatement("updateResult"), params);
    }
}